Repository navigation
feat(cli): add agent markers other detectors use, verified upstream - #7425
Conversation
Compared std-env, @vercel/detect-agent, am-i-vibing and agent-cli-detector against our rules and kept only markers the agent itself sets on the shells it spawns: Auggie AUGMENT_AGENT, Amp AMP_CURRENT_THREAD_ID, Cursor CURSOR_CONVERSATION_ID and CURSOR_SANDBOX, Cline CLI CLINE_WRAPPER_PATH, Muse MUSE_RELEASE_INFO, and Warp Oz OZ_RUN_ID (after the harnesses it wraps). Claude Code now keys on CLAUDE_CODE_CHILD_SESSION or CLAUDE_CODE_ENTRYPOINT. Its IDE extensions also set CLAUDECODE in the integrated terminal a person types into, so CLAUDECODE alone counted that person as an agent: no prompts, agent-mode login. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Edit accuracy: accurate 267 (base branch 267), smooth 113 of thoseThe gate passes. Quarantined, measured but not gated (8)
Unstable (2)
|
main already sat at the edge of the 1% tolerance; the new agent rules put the packed CLI 842 bytes past it (8062664 vs 7982002 + 1%). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Verdict: APPROVE · 0 blocker · 0 important · 2 nits · head 5d2ee2e3
The Claude Code change holds up against the 2.1.319 binary and VS Code extension. The Bash tool sets CLAUDE_CODE_CHILD_SESSION along with CLAUDECODE. claude puts CLAUDE_CODE_ENTRYPOINT in its own env at startup, so every child inherits it. The extension's terminals set neither marker. Both nits are comment wording ↓
Scope, blast radius, CI
isUnattended: a person whose IDE terminal has onlyCLAUDECODEnow gets prompts again. Every real Claude Code spawn still matches throughCHILD_SESSIONorENTRYPOINT, including stdio MCP servers and versions before 2.1.172, so agents still get no prompts.auth login:agentShellOnThisMachineonly matters when stdout is not a TTY, so theCLAUDECODEchange has no effect on a TTY user. The new markers send more agents without a TTY to the browser sign-in, which is the intended result.desktopApp:someoneToTellshort-circuits ontty, so a person at a terminal sees no change. Agents with the new markers now get the hint. Two other callers ofdetectAgentRuntimealso change behaviour:feedback.ts(an IDE-terminal person gets the normal TTY prompt instead of the agent line) and the Studio__HF_CLI_AGENT_RUNTIMElabel. Both changes are correct.- I found no downstream enum for
AgentRuntimethat needsauggie,museorwarp_ozadded.usage.tsdetectHarnessstill keys onCLAUDECODE, which is fine for that command. - Spot checks: Cline
apps/cli/bin/clinesetsCLINE_WRAPPER_PATHinchildEnv. Warp's local harness panes are hidden and launched off-screen, soOZ_RUN_IDdoes not leak into a terminal a person types in. OpenCode, which Oz also wraps, is matched beforewarp_oz. - Local runs: telemetry/*, attendedTerminal, auth login, desktopApp, telemetryIdentity and usage gave 616/616.
cli.agentModegave 518/518. I ran the suites both with and without Claude Code markers in the environment. - CI at
5d2ee2e3: CI, Windows render verification, regression, CodeQL and Comments are all green. The budget bump is explained in the PR body.
— Genesis
| // every child (main.tsx:527). Both propagate to spawned subprocesses. | ||
| // Source: confirmed by @magi from Claude Code internal source. | ||
| // Claude Code sets CLAUDE_CODE_CHILD_SESSION on what its tools spawn, and an | ||
| // inherited CLAUDE_CODE_ENTRYPOINT (older versions). Not CLAUDECODE: its IDE |
There was a problem hiding this comment.
nit: CLAUDE_CODE_ENTRYPOINT is not only from older versions. Current claude (2.1.319) sets it to cli/sdk-cli/mcp at startup. It is also the only Claude marker that reaches a stdio MCP server (Claude Code removes CHILD_SESSION there) and shells from versions before 2.1.172. Calling it "older versions" invites someone to delete it later, which would break detection in exactly those cases.
| // inherited CLAUDE_CODE_ENTRYPOINT (older versions). Not CLAUDECODE: its IDE | |
| // inherited CLAUDE_CODE_ENTRYPOINT (MCP servers, pre-2.1.172). Not CLAUDECODE: its IDE |
| // Source: https://github.com/warpdotdev/warp (crates/warp_cli/src/lib.rs) | ||
| { name: "warp_oz", check: (env) => typeof env["OZ_RUN_ID"] === "string" }, | ||
| // An app built on the Claude Agent SDK, running a command outside Claude | ||
| // Code's own shell tool (that path sets CLAUDECODE, caught above). The SDK |
There was a problem hiding this comment.
nit: this comment is out of date now that the rule no longer reads CLAUDECODE.
| // Code's own shell tool (that path sets CLAUDECODE, caught above). The SDK | |
| // Code's own shell tool (that path sets CLAUDE_CODE_CHILD_SESSION, caught above). The SDK |
CLAUDE_CODE_ENTRYPOINT is set by current Claude Code versions too, and it is the only Claude marker MCP servers inherit, so it is not an "older versions" fallback. The Agent SDK comment still said Claude Code's shell tool sets CLAUDECODE; the rule keys on CLAUDE_CODE_CHILD_SESSION. Follow-up to review nits on #7425. Comments only. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ygen-com#7426) CLAUDE_CODE_ENTRYPOINT is set by current Claude Code versions too, and it is the only Claude marker MCP servers inherit, so it is not an "older versions" fallback. The Agent SDK comment still said Claude Code's shell tool sets CLAUDECODE; the rule keys on CLAUDE_CODE_CHILD_SESSION. Follow-up to review nits on heygen-com#7425. Comments only. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
What
Markers from other detectors, verified upstream. I compared our rules with
std-env,@vercel/detect-agent,am-i-vibingandagent-cli-detector, and kept only markers the agent itself sets on the shells it spawns:auggie, new)AUGMENT_AGENT@augmentcode/auggiebundle: the shell tool is built withenv: { AUGMENT_AGENT: "1" }AMP_CURRENT_THREAD_ID@sourcegraph/ampbundle: the Bash tool and toolbox subprocesses get itCURSOR_CONVERSATION_ID,CURSOR_SANDBOXCURSOR_SANDBOXdocumented in cursor.com run-modesCLINE_WRAPPER_PATHcline/clineapps/cli/bin/clinemuse, new)MUSE_RELEASE_INFOmuse-launcher.shexports it before execwarp_oz, new)OZ_RUN_IDwarpdotdev/warpcrates/warp_cli/src/lib.rs. Checked after the harnesses it wraps (Claude Code, Codex, Gemini).Claude Code fix. The rule now keys on
CLAUDE_CODE_CHILD_SESSION(or the inheritedCLAUDE_CODE_ENTRYPOINT), notCLAUDECODE. Claude Code's docs say its IDE extensions also setCLAUDECODEin their integrated terminals, so a person typing in that terminal counted as an agent:isUnattendedstopped prompting them, andauth logintook the agent path.Package size budget:
@hyperframes/clipacked budget goes from 7982002 to 8062664, the measured size.mainalready sat at the edge of the 1% tolerance, and these rules put the packed CLI 842 bytes past it.Cleanup: fixes the stale "rules above" wording from fix(cli): let an agent's own name beat editor and host markers #7424 review, plus two citations the comment gate flags.
Why
Follow-up to #7423 / #7424.
Left out on purpose: user settings and tokens such as
COPILOT_MODEL,COPILOT_ALLOW_ALL,GOOSE_PROVIDER,OPENCODE_CLIENT,JUNIE_DATA,FACTORY_ENV. Also left out:CURSOR_TRACE_ID,REPLIT_SESSION, Bolt's,KILO_RUN_ID);DEVIN_PROJECT_DIR,DROID_PROJECT_DIR);KIRO_SESSION_ID,ANTIGRAVITY_TRAJECTORY_ID).Related work
Refs #7423, #7424
How
warp_ozgoes just before the Agent SDK rule.CLAUDECODE=1now useCLAUDE_CODE_CHILD_SESSION=1.CLAUDECODEalone (the IDE terminal) is neitherclaude_codenor agent-driven.Test plan
tsc --noEmit, comment-citations and comment-ratchet also pass.— Rames
🤖 Generated with Claude Code